package com.denimgroup.threadfix.data.entities;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.codehaus.jackson.annotate.JsonIgnore;

@Entity
@Table(name = "VulnerabilityComment")
public class VulnerabilityComment extends AuditableEntity {

	private static final long serialVersionUID = -2819882984861551170L;

	private String comment;
	private User user;
	private Date time;
	private Vulnerability vulnerability;
	private Integer deletedVulnerabilityId;
	
	public static final int COMMENT_LENGTH = 200;

	@ManyToOne
	@JoinColumn(name = "vulnerabilityId")
	public Vulnerability getVulnerability() {
		return vulnerability;
	}

	public void setVulnerability(Vulnerability vulnerability) {
		this.vulnerability = vulnerability;
	}
	
	@Column(length = COMMENT_LENGTH, nullable = true)
	@JsonIgnore
	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	@ManyToOne
	@JoinColumn(nullable = true, name = "userId")
	@JsonIgnore
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Temporal(TemporalType.TIMESTAMP)
	public Date getTime() {
		return time;
	}

	public void setTime(Date time) {
		this.time = time;
	}

	@Column(nullable = true)
	public Integer getDeletedVulnerabilityId() {
		return deletedVulnerabilityId;
	}

	public void setDeletedVulnerabilityId(Integer deletedVulnerabilityId) {
		this.deletedVulnerabilityId = deletedVulnerabilityId;
	}
}
